import { getStore, setStore } from '@/utils/store'

const common ={
  state: {
    isCollapse: false,
    isFullScren: false,
    topMenuIndex: getStore({ name: 'topMenuIndex' }) || 0,
    themeKey: getStore({ name: 'themeKey' }) || '',
    sizeKey:getStore({ name: 'sizeKey' }) || 'default',
  },
  actions: {},
  mutations: {
    SET_COLLAPSE: (state) => {
      state.isCollapse = !state.isCollapse
    },
    SET_FULLSCREN: (state) => {
      state.isFullScren = !state.isFullScren
    },
    SET_TOP_MENU_INDEX: (state, topMenuIndex) => {
      state.topMenuIndex = topMenuIndex
      setStore({
        name: 'topMenuIndex',
        content: state.topMenuIndex
      })
    },
    SET_THEME_KEY:(state,themeKey) =>{
      state.themeKey = themeKey;
      setStore({
        name: 'themeKey',
        content: state.themeKey,
      })
    },
    SET_SIZE_KEY:(state,sizeKey) =>{
      state.sizeKey = sizeKey;
      setStore({
        name: 'sizeKey',
        content: state.sizeKey,
      })
    },
  }
  
}
export default common